﻿#ifndef HOMEPAGE_H
#define HOMEPAGE_H

#include <QWidget>

#include <QTimer>
#include <QDateTime>
#include <QMessageBox>
#include "OpcUA/opcua_qthread.h"
#include "OpcUA/plcdataconversion.h"
#include "SQLite/mysqlite.h"

#include <Trunk/graphicswidget.h>

namespace Ui {
class HomePage;
}

class HomePage : public QWidget
{
    Q_OBJECT

public:
    explicit HomePage(OpcUA_QThread * opcUA, QWidget *parent = nullptr);
    ~HomePage();

signals:
    void signals_sendTemperature(int16_t temperature1, int16_t temperature2);

public slots:
    void on_FlowChart_Start();

    void on_FlowChart_Stop();

    void on_receiveDesiredValue(QVector<int16_t> flowmeter, QVector<int16_t> pressuremeter);

private slots:
    void on_readData();

    void on_receiveData(QVector<int16_t> flowmeter, QVector<int16_t> pressuremeter, QVector<bool> valve, QVector<int16_t> temperature, int32_t dintPressure, bool success);

    void on_writeDB(const QVector<int16_t>& result1, QVector<bool>& result2, bool success);

    void on_dbCreateFinished(bool success, QString dbName);

private:
    OpcUA_QThread * myOpcUA;

    Ui::HomePage *ui;

    QTimer * myReadDataTimer;

    MySQLite * mySQLite;

    bool  myReadyStatus = false;

    GraphicsWidget * myGraphicsWidget;


};

#endif // HOMEPAGE_H
